<template>
	<view class="main">
		<textarea class="textarea" v-model="form.content" placeholder="请输入您的建议或意见..." :maxlength="-1" />
		<button class="btn" @click="handleSubmit">提交</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			form: {
				content: "",
			},
		};
	},
	methods: {
		async handleSubmit() {
			if (!this.form.content) {
				return uni.showToast({
					title: "请输入您的建议或意见...",
					icon: 'none'
				})

			}
			const configInfo = await this.$store.dispatch('GETCONFIGINFO')
			const collection = uniCloud.database().collection("feedback")
			const res = await collection.add({
				...this.form,
				applyId: configInfo.appId,
				appName: this.$store.state.configInfo.title
			})
			if (!res.errCode) {
				uni.showToast({
					title: "提交成功",
					icon: "success"
				})
				setTimeout(() => {
					uni.navigateBack()
				}, 1500)
			}
		},
	},
};
</script>

<style scoped lang="scss">
.main {
	padding: 32rpx;
}

.textarea {
	width: 100%;
	background-color: #fff;
	box-shadow: 1rpx 4rpx 4rpx 1rpx rgba(0, 0, 0, 0.1);
	border-radius: 24rpx;
	padding: 32rpx;
	box-sizing: border-box;
}

.btn {
	margin-top: 32rpx;
	background-image: linear-gradient(to bottom right, #FE73DA, #FF9056);
	color: #fff;
	border-radius: 24rpx;
	width: 100%;
}
</style>